/**
 * Created by JiangTao on 2017/2/8.
 */
var Dracula = {
    post: function (api, data, successCallback) {
        $.ajax({
            type: 'POST',
            url: api,
            data: JSON.stringify(data),
            contentType: "application/json",
            success: function (resJson) {
                if (typeof(successCallback) == 'function' && resJson) {
                    successCallback(resJson);
                }
            },
            error: function (xhr) {
            }
        });
    },
    alert: function (msg, callback) {
        var topWin = window.parent ? window.parent : window;
        var index = topWin.layer.alert(msg, {}, function () {
            if (typeof(callback) == 'function') {
                callback();
            }
            topWin.layer.close(index);
        });
    },
    util: {
        isEmpty: function (input) {
            if (input == undefined || $.trim(input) === '') {
                return true;
            }
            return false;
        },
        exportExcel: function (formQuery) {
            var $exportFrame = $('#exportFrame', window.parent.document);
            var $frameBody = $exportFrame.contents().find("body");
            $frameBody.empty().append('<form id="exportForm" action="filesupload/export.shtml" method="post" enctype="application/x-www-form-urlencoded"><input type="hidden" name="query" value="' + encodeURI(JSON.stringify(formQuery)) + '"></form>');
            $frameBody.find('#exportForm').submit();
        }
    }
};